package org.dashboard.client.widget;

import com.google.gwt.dom.client.Style;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * Created by IntelliJ IDEA.
 * User: g41533
 * Date: 23-02-11
 * Time: 23:31
 * To change this template use File | Settings | File Templates.
 */
public class DoubleWidgetHolder extends DockLayoutPanel {

    public DoubleWidgetHolder(int refreshInterval, int width, int height, final Widget one, final Widget two) {
        super(Style.Unit.PCT);
        setSize(width+"px", height+"px");
        addNorth(one, 100);
        addSouth(two, 100);
        one.setVisible(true);
        two.setVisible(false);

        final Timer timer = new Timer() {
            @Override
            public void run() {
                boolean a = one.isVisible();
                one.setVisible(!a);
                animate(2000);
                two.setVisible(a);
                animate(2000);
            }
        };
        timer.scheduleRepeating(refreshInterval);
    }
}
